package com.user.utils;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;

/**
 * @Author : Yu
 * @Date 2023/9/20 22:48
 */
public class Encrypt {
    // 16位自定义密码
    static String key = "0123456789012345";

    // 生成密钥
    static byte[] byteKey = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue(), key.getBytes()).getEncoded();

    static SymmetricCrypto aes = SecureUtil.aes(byteKey);

    // 加密
    public static String cipher(String password) {
        return aes.encryptBase64(password);
    }

    // 解密
    public static String decrypt(String encryptData) {
        return aes.decryptStr(encryptData);
    }


}
